import axios from "axios";
// eslint-disable-next-line
export default {
  //获取优惠券数据
  get: ({ curPage, eachPage }) =>
    axios
      .get("/api/carts", {
        params: {
          curPage,
          eachPage,
        },
      })
      .then(({ data }) => data),
  //新增购物车
  createCart: ({ detail }) =>
    axios.post("/api/carts", { detail }).then(({ data }) => data),
  //通过id获取某一条购物车数据
  getOne: (_id) =>
    axios
      .get(`/api/carts/${_id}`, { params: { _id } })
      .then((response) => response.data),
  //通过id修改某一条购物车数据
  changeOne: ({ _id, detail }) =>
    axios
      .put(`/api/carts/change`, {
        _id,
        detail,
      })
      .then((response) => response.data),
  //删除购物车(用户注销时调用)
  delCart: (_id) =>
    axios.delete("/api/carts/del", { data: { _id } }).then(({ data }) => data),
};
